package tests;

import common.Utils;
import org.openqa.selenium.By;

public class LovePage extends Utils {
    //TODO
    //FIXME 这个页面有点问题 《已解决》
    public static String url = "http://124.223.114.169:8081/loveMusic_copy2.html";

    public LovePage() {
        super(url);
    }

    /**
     * //查询歌曲
     */
    public void selectLoveMusic(){
        //不用，构造方法，在创建对象的时候就传了URL。driver.get(url);
        driver.findElement(By.cssSelector("#exampleInputName2")).sendKeys("青");
        driver.findElement(By.cssSelector("#submit1")).click();

        //怎么判断真的查了呢？？？


    }


    /**
     * //返回主页
     */
    public void backToList() throws InterruptedException {
        System.out.println("back-start");
        Thread.sleep(8000);
        driver.findElement(By.cssSelector("#body > div.container > div:nth-child(3) > a")).click();
        Thread.sleep(1000);
        String exp = driver.getCurrentUrl();
        System.out.println(exp);
        assert exp.equals("http://124.223.114.169:8081/list.html");
        System.out.println("back-finish");
    }

    /**
     * //移除歌曲
     */
    public void removeLoveMusic() throws InterruptedException {
        System.out.println("removeLoveMusic-start");
        driver.findElement(By.cssSelector("#info > tr > td:nth-child(4) > button")).click();
        Thread.sleep(1000);
        driver.switchTo().alert().accept();
        //怎么判断删除成功了呢？
        System.out.println("removeLoveMusic-finish");
    }

    /**
     * //播放歌曲
     */

    public void listenMusic() {

        driver.findElement(By.cssSelector("#info > tr > td:nth-child(3) > button")).click();
    }
}
